CSharpTest.Net
Run(String[]) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Run Method : Run(String[]) Method

arguments

Glossary Item Box

Runs the process with additional arguments and returns the exit code.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Run( _
   ByVal ParamArray arguments() As String _
) As Integer
C# 
public int Run( 
   params string[] arguments
)

Parameters

arguments

Example

Library/Library.Test/TestAssemblyRunner.cs

C#Copy Code
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    StringWriter wtr = new StringWriter();
    StringWriter err = new StringWriter();
    ProcessOutputEventHandler handler =
            delegate(object o, ProcessOutputEventArgs e)
            { if (e.Error) err.WriteLine(e.Data); else wtr.WriteLine(e.Data); };

    runner.OutputReceived += handler;

    Assert.AreEqual(1, runner.Run("command-line-argrument"));
    Assert.AreEqual("std-err", err.ToString().Trim());

    StringReader rdr = new StringReader(wtr.ToString());
    Assert.AreEqual("WorkingDirectory = " + Environment.CurrentDirectory, rdr.ReadLine());
    Assert.AreEqual("argument[0] = command-line-argrument", rdr.ReadLine());
    Assert.AreEqual("std-input:", rdr.ReadLine());
    Assert.AreEqual(null, rdr.ReadLine());
}
VB.NETCopy Code
Using runner As New AssemblyRunner(Exe)
    Dim wtr As New StringWriter()
    Dim err As New StringWriter()
    Dim handler As ProcessOutputEventHandler = Function(o As Object, e As ProcessOutputEventArgs) Do
        If e.[Error] Then
            err.WriteLine(e.Data)
        Else
            wtr.WriteLine(e.Data)
        End If
    End Function

    runner.OutputReceived += handler

    Assert.AreEqual(1, runner.Run("command-line-argrument"))
    Assert.AreEqual("std-err", err.ToString().Trim())

    Dim rdr As New StringReader(wtr.ToString())
    Assert.AreEqual("WorkingDirectory = " + Environment.CurrentDirectory, rdr.ReadLine())
    Assert.AreEqual("argument[0] = command-line-argrument", rdr.ReadLine())
    Assert.AreEqual("std-input:", rdr.ReadLine())
    Assert.AreEqual(Nothing, rdr.ReadLine())
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys